package com.neuedu.nevserver.vo;

/**
 * @author: sjy
 */
public class ResultVO<T> {
    private String reason; //本次业务操作响应消息
    private boolean flag;//本次业务操作响应状态 true/false
    private T result;

    //成功-返回结果集
    public static <T> ResultVO<T> success(String reason,T result){
        ResultVO<T> model=new ResultVO<>();
        model.setFlag(true);
        model.setReason(reason);
        model.setResult(result);
        return model;
    }
    //成功-无返回结果集
    public static  ResultVO success(String reason){
        ResultVO model=new ResultVO<>();
        model.setFlag(true);
        model.setReason(reason);
        return model;
    }
    //失败
    public static  ResultVO fail(String reason){
        ResultVO model=new ResultVO<>();
        model.setFlag(false);
        model.setReason(reason);
        return model;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "ResultVO{" +
                "reason='" + reason + '\'' +
                ", flag=" + flag +
                ", result=" + result +
                '}';
    }
}
